(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 10.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       158,          7]
NotebookDataLength[     16868,        442]
NotebookOptionsPosition[     15788,        398]
NotebookOutlinePosition[     16147,        414]
CellTagsIndexPosition[     16104,        411]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{
Cell["Two dimensional linear mapping", "Section",
 CellChangeTimes->{{3.665056388022813*^9, 3.665056403533696*^9}, {
  3.6650728573299503`*^9, 3.665072857863494*^9}, {3.6650741130477047`*^9, 
  3.665074113439701*^9}}],

Cell[CellGroupData[{

Cell["Element coordinates", "Section",
 CellChangeTimes->{{3.66505651939773*^9, 3.665056530229817*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"p0", "=", 
   RowBox[{"{", 
    RowBox[{"0", ",", "0", ",", "0"}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"p1", "=", 
   RowBox[{"{", 
    RowBox[{"1", ",", "0", ",", "0"}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"p2", "=", 
   RowBox[{"{", 
    RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"p3", "=", 
   RowBox[{"{", 
    RowBox[{"1", ",", "1", ",", "0"}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"elT", "=", 
   RowBox[{"{", 
    RowBox[{"p0", ",", "p1", ",", "p2"}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"elQ", "=", 
   RowBox[{"{", 
    RowBox[{"p0", ",", "p1", ",", "p3", ",", "p2"}], "}"}]}], ";"}]}], "Input",\

 CellChangeTimes->{{3.665056532225173*^9, 3.665056557670353*^9}, {
  3.665056663998806*^9, 3.665056667566579*^9}, {3.665069927849292*^9, 
  3.665069933152289*^9}, {3.6650704421204147`*^9, 3.665070459721319*^9}, {
  3.665070618456341*^9, 3.665070661072359*^9}, {3.66507184700273*^9, 
  3.665071859478033*^9}, {3.665071892898653*^9, 3.665071919984729*^9}, {
  3.665072091322913*^9, 3.665072108176559*^9}, {3.665074031323126*^9, 
  3.665074047704768*^9}, {3.665074088757938*^9, 3.665074130880561*^9}, {
  3.6651544450408173`*^9, 3.665154445176237*^9}, {3.6651544844885473`*^9, 
  3.6651545243236*^9}}]
}, Open  ]],

Cell[CellGroupData[{

Cell["Linear mapping", "Section",
 CellChangeTimes->{{3.665056503589859*^9, 3.665056506709682*^9}, {
  3.6650728608181543`*^9, 3.665072861367488*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{"L\[Phi]T", "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"1", "-", "\[Xi]", "-", "\[Eta]"}], ",", "\[Xi]", ",", 
     "\[Eta]"}], "}"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"L\[Phi]Q", "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{
      FractionBox["1", "4"], " ", 
      RowBox[{"(", 
       RowBox[{"1", "-", "\[Eta]"}], ")"}], " ", 
      RowBox[{"(", 
       RowBox[{"1", "-", "\[Xi]"}], ")"}]}], ",", 
     RowBox[{
      FractionBox["1", "4"], " ", 
      RowBox[{"(", 
       RowBox[{"1", "-", "\[Eta]"}], ")"}], " ", 
      RowBox[{"(", 
       RowBox[{"1", "+", "\[Xi]"}], ")"}]}], ",", 
     RowBox[{
      FractionBox["1", "4"], " ", 
      RowBox[{"(", 
       RowBox[{"1", "+", "\[Eta]"}], ")"}], " ", 
      RowBox[{"(", 
       RowBox[{"1", "+", "\[Xi]"}], ")"}]}], ",", 
     RowBox[{
      FractionBox["1", "4"], " ", 
      RowBox[{"(", 
       RowBox[{"1", "+", "\[Eta]"}], ")"}], " ", 
      RowBox[{"(", 
       RowBox[{"1", "-", "\[Xi]"}], ")"}]}]}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"XL", "[", 
    RowBox[{"\[Phi]_", ",", "xcoor_"}], "]"}], "=", 
   RowBox[{"\[Phi]", ".", "xcoor"}]}], ";"}]}], "Input",
 CellChangeTimes->{{3.665056561088571*^9, 3.6650566175345783`*^9}, {
  3.6650712755411873`*^9, 3.665071275963586*^9}, {3.665071415514318*^9, 
  3.665071456311211*^9}, {3.6650715078345137`*^9, 3.6650715500572367`*^9}, {
  3.665071617338531*^9, 3.6650716305688868`*^9}, {3.6650716786338463`*^9, 
  3.66507175608843*^9}, {3.665073070166052*^9, 3.665073071491281*^9}, {
  3.665074135547559*^9, 3.665074140920485*^9}, {3.6651541925629063`*^9, 
  3.665154220217379*^9}, {3.6651542653781147`*^9, 3.6651542820112257`*^9}}]
}, Open  ]],

Cell[CellGroupData[{

Cell["X(\[Xi],\[Eta]) mapping Triangles", "Section",
 CellChangeTimes->{{3.665056622597714*^9, 3.665056627709565*^9}, {
  3.665072864090125*^9, 3.665072870759647*^9}, {3.665154288544819*^9, 
  3.665154289871359*^9}, {3.66515825423489*^9, 3.6651582546399612`*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"X", "[", 
    RowBox[{"\[Phi]_", ",", "xcoor_"}], "]"}], "=", 
   RowBox[{"XL", "[", 
    RowBox[{"\[Phi]", ",", "xcoor"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"GradXexp", "=", 
   RowBox[{"Grad", "[", 
    RowBox[{
     RowBox[{"X", "[", 
      RowBox[{"L\[Phi]T", ",", "xcoor"}], "]"}], ",", 
     RowBox[{"{", 
      RowBox[{"\[Xi]", ",", "\[Eta]"}], "}"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GradX", "[", "xcoor_", "]"}], "=", "GradXexp"}], ";"}]}], "Input",\

 CellChangeTimes->{{3.665056639152625*^9, 3.665056647039544*^9}, {
   3.6650706677284117`*^9, 3.66507073187227*^9}, 3.66507076215528*^9, {
   3.665070794744328*^9, 3.665070832907311*^9}, {3.665071141874402*^9, 
   3.6650711636644983`*^9}, {3.665071200423388*^9, 3.665071208700766*^9}, {
   3.665071479154251*^9, 3.665071480202228*^9}, {3.665072220739332*^9, 
   3.665072245560796*^9}, {3.665072277544651*^9, 3.6650722956167097`*^9}, {
   3.6650723488254213`*^9, 3.6650723498786097`*^9}, {3.665072965483306*^9, 
   3.6650729947325*^9}, 3.665154308354871*^9, {3.6651545433686457`*^9, 
   3.665154543929151*^9}}],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{"\[Xi]p", "=", "0.25"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"\[Eta]p", "=", "0.25"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"For", "[", 
   RowBox[{
    RowBox[{"i", "=", "1"}], ",", 
    RowBox[{"i", "\[LessEqual]", " ", "1"}], ",", 
    RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Print", "[", 
      RowBox[{"{", 
       RowBox[{"\"\<X = \>\"", ",", 
        RowBox[{
         RowBox[{"X", "[", 
          RowBox[{"L\[Phi]T", ",", "elT"}], "]"}], "/.", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Xi]", "->", "\[Xi]p"}], ",", 
           RowBox[{"\[Eta]", "\[Rule]", "\[Eta]p"}]}], "}"}]}]}], "}"}], 
      "]"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Print", "[", 
      RowBox[{"{", 
       RowBox[{"\"\<Grad of X = \>\"", ",", 
        RowBox[{
         RowBox[{"GradX", "[", "elT", "]"}], "/.", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Xi]", "->", "\[Xi]p"}], ",", 
           RowBox[{"\[Eta]", "\[Rule]", "\[Eta]p"}]}], "}"}]}], ",", 
        RowBox[{
         RowBox[{"Dimensions", "[", 
          RowBox[{"GradX", "[", "elT", "]"}], "]"}], " ", "/.", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Xi]", "->", "\[Xi]p"}], ",", 
           RowBox[{"\[Eta]", "\[Rule]", "\[Eta]p"}]}], "}"}]}]}], "}"}], 
      "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "Input",
 CellChangeTimes->{{3.6650706860233383`*^9, 3.6650706948188753`*^9}, {
   3.665070738491704*^9, 3.665070744440419*^9}, {3.665070836424273*^9, 
   3.6650709058652067`*^9}, {3.665070959130547*^9, 3.6650710695929823`*^9}, 
   3.665071134587174*^9, {3.665071214785551*^9, 3.665071235995173*^9}, {
   3.665071269753755*^9, 3.665071291340974*^9}, 3.665074107921599*^9, {
   3.6651543150436163`*^9, 3.665154363371455*^9}, {3.6651543947714653`*^9, 
   3.665154404101534*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"X = \"\>", ",", 
   RowBox[{"{", 
    RowBox[{"0.25`", ",", "0.25`", ",", "0"}], "}"}]}], "}"}]], "Print",
 CellChangeTimes->{{3.665070866585092*^9, 3.665070906424777*^9}, 
   3.6650709712600727`*^9, {3.665071006547703*^9, 3.665071048654336*^9}, {
   3.6650710975833387`*^9, 3.66507114401719*^9}, {3.665071236783328*^9, 
   3.665071291702422*^9}, {3.665071439691434*^9, 3.665071459661374*^9}, 
   3.665071512236197*^9, 3.665071699997882*^9, 3.665072213278562*^9, 
   3.665072247063212*^9, 3.665072302253025*^9, {3.665072352853303*^9, 
   3.66507236396906*^9}, {3.665072971504951*^9, 3.6650730065083857`*^9}, 
   3.6650730728468943`*^9, 3.665074108768221*^9, 3.665074148034444*^9, 
   3.6651540832960587`*^9, 3.665154320487912*^9, {3.665154364328169*^9, 
   3.665154367906761*^9}, {3.6651544053421497`*^9, 3.6651544511495523`*^9}, {
   3.665154535759304*^9, 3.6651545456097593`*^9}, 3.6651546314107857`*^9, 
   3.665154718256198*^9}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"Grad of X = \"\>", ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"1", ",", "0", ",", "0"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"0", ",", "1", ",", "0"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"2", ",", "3"}], "}"}]}], "}"}]], "Print",
 CellChangeTimes->{{3.665070866585092*^9, 3.665070906424777*^9}, 
   3.6650709712600727`*^9, {3.665071006547703*^9, 3.665071048654336*^9}, {
   3.6650710975833387`*^9, 3.66507114401719*^9}, {3.665071236783328*^9, 
   3.665071291702422*^9}, {3.665071439691434*^9, 3.665071459661374*^9}, 
   3.665071512236197*^9, 3.665071699997882*^9, 3.665072213278562*^9, 
   3.665072247063212*^9, 3.665072302253025*^9, {3.665072352853303*^9, 
   3.66507236396906*^9}, {3.665072971504951*^9, 3.6650730065083857`*^9}, 
   3.6650730728468943`*^9, 3.665074108768221*^9, 3.665074148034444*^9, 
   3.6651540832960587`*^9, 3.665154320487912*^9, {3.665154364328169*^9, 
   3.665154367906761*^9}, {3.6651544053421497`*^9, 3.6651544511495523`*^9}, {
   3.665154535759304*^9, 3.6651545456097593`*^9}, 3.6651546314107857`*^9, 
   3.6651547182649183`*^9}]
}, Open  ]]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["X(\[Xi],\[Eta]) mapping Quadrilaterals", "Section",
 CellChangeTimes->{{3.665056622597714*^9, 3.665056627709565*^9}, {
  3.665072864090125*^9, 3.665072870759647*^9}, {3.665154288544819*^9, 
  3.665154289871359*^9}, {3.665154688360861*^9, 3.665154695479601*^9}, {
  3.665158257448161*^9, 3.66515825789596*^9}}],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"X", "[", 
    RowBox[{"\[Phi]_", ",", "xcoor_"}], "]"}], "=", 
   RowBox[{"XL", "[", 
    RowBox[{"\[Phi]", ",", "xcoor"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"GradXexp", "=", 
   RowBox[{"Grad", "[", 
    RowBox[{
     RowBox[{"X", "[", 
      RowBox[{"L\[Phi]Q", ",", "xcoor"}], "]"}], ",", 
     RowBox[{"{", 
      RowBox[{"\[Xi]", ",", "\[Eta]"}], "}"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GradX", "[", "xcoor_", "]"}], "=", "GradXexp"}], ";"}]}], "Input",\

 CellChangeTimes->{{3.665056639152625*^9, 3.665056647039544*^9}, {
   3.6650706677284117`*^9, 3.66507073187227*^9}, 3.66507076215528*^9, {
   3.665070794744328*^9, 3.665070832907311*^9}, {3.665071141874402*^9, 
   3.6650711636644983`*^9}, {3.665071200423388*^9, 3.665071208700766*^9}, {
   3.665071479154251*^9, 3.665071480202228*^9}, {3.665072220739332*^9, 
   3.665072245560796*^9}, {3.665072277544651*^9, 3.6650722956167097`*^9}, {
   3.6650723488254213`*^9, 3.6650723498786097`*^9}, {3.665072965483306*^9, 
   3.6650729947325*^9}, 3.665154308354871*^9, {3.6651545433686457`*^9, 
   3.665154543929151*^9}, {3.6651546991987743`*^9, 3.6651546995682507`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[{
 RowBox[{
  RowBox[{"\[Xi]p", "=", "0.25"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"\[Eta]p", "=", "0.25"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"For", "[", 
   RowBox[{
    RowBox[{"i", "=", "1"}], ",", 
    RowBox[{"i", "\[LessEqual]", " ", "1"}], ",", 
    RowBox[{"i", "++"}], ",", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Print", "[", 
      RowBox[{"{", 
       RowBox[{"\"\<X = \>\"", ",", 
        RowBox[{
         RowBox[{"X", "[", 
          RowBox[{"L\[Phi]Q", ",", "elQ"}], "]"}], "/.", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Xi]", "->", "\[Xi]p"}], ",", 
           RowBox[{"\[Eta]", "\[Rule]", "\[Eta]p"}]}], "}"}]}]}], "}"}], 
      "]"}], ";", "\[IndentingNewLine]", 
     RowBox[{"Print", "[", 
      RowBox[{"{", 
       RowBox[{"\"\<Grad of X = \>\"", ",", 
        RowBox[{
         RowBox[{"GradX", "[", "elQ", "]"}], "/.", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Xi]", "->", "\[Xi]p"}], ",", 
           RowBox[{"\[Eta]", "\[Rule]", "\[Eta]p"}]}], "}"}]}], ",", 
        RowBox[{
         RowBox[{"Dimensions", "[", 
          RowBox[{"GradX", "[", "elQ", "]"}], "]"}], " ", "/.", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"\[Xi]", "->", "\[Xi]p"}], ",", 
           RowBox[{"\[Eta]", "\[Rule]", "\[Eta]p"}]}], "}"}]}]}], "}"}], 
      "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";"}]}], "Input",
 CellChangeTimes->{{3.6650706860233383`*^9, 3.6650706948188753`*^9}, {
   3.665070738491704*^9, 3.665070744440419*^9}, {3.665070836424273*^9, 
   3.6650709058652067`*^9}, {3.665070959130547*^9, 3.6650710695929823`*^9}, 
   3.665071134587174*^9, {3.665071214785551*^9, 3.665071235995173*^9}, {
   3.665071269753755*^9, 3.665071291340974*^9}, 3.665074107921599*^9, {
   3.6651543150436163`*^9, 3.665154363371455*^9}, {3.6651543947714653`*^9, 
   3.665154404101534*^9}, {3.6651547059238253`*^9, 3.665154716666963*^9}, {
   3.665154864122673*^9, 3.6651548836186666`*^9}}],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"X = \"\>", ",", 
   RowBox[{"{", 
    RowBox[{"0.625`", ",", "0.625`", ",", "0"}], "}"}]}], "}"}]], "Print",
 CellChangeTimes->{{3.665070866585092*^9, 3.665070906424777*^9}, 
   3.6650709712600727`*^9, {3.665071006547703*^9, 3.665071048654336*^9}, {
   3.6650710975833387`*^9, 3.66507114401719*^9}, {3.665071236783328*^9, 
   3.665071291702422*^9}, {3.665071439691434*^9, 3.665071459661374*^9}, 
   3.665071512236197*^9, 3.665071699997882*^9, 3.665072213278562*^9, 
   3.665072247063212*^9, 3.665072302253025*^9, {3.665072352853303*^9, 
   3.66507236396906*^9}, {3.665072971504951*^9, 3.6650730065083857`*^9}, 
   3.6650730728468943`*^9, 3.665074108768221*^9, 3.665074148034444*^9, 
   3.6651540832960587`*^9, 3.665154320487912*^9, {3.665154364328169*^9, 
   3.665154367906761*^9}, {3.6651544053421497`*^9, 3.6651544511495523`*^9}, {
   3.665154535759304*^9, 3.6651545456097593`*^9}, 3.6651546314107857`*^9, 
   3.665154718308558*^9, {3.665154864485486*^9, 3.665154884133259*^9}}],

Cell[BoxData[
 RowBox[{"{", 
  RowBox[{"\<\"Grad of X = \"\>", ",", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"0.5`", ",", "0.`", ",", "0"}], "}"}], ",", 
     RowBox[{"{", 
      RowBox[{"0.`", ",", "0.5`", ",", "0"}], "}"}]}], "}"}], ",", 
   RowBox[{"{", 
    RowBox[{"2", ",", "3"}], "}"}]}], "}"}]], "Print",
 CellChangeTimes->{{3.665070866585092*^9, 3.665070906424777*^9}, 
   3.6650709712600727`*^9, {3.665071006547703*^9, 3.665071048654336*^9}, {
   3.6650710975833387`*^9, 3.66507114401719*^9}, {3.665071236783328*^9, 
   3.665071291702422*^9}, {3.665071439691434*^9, 3.665071459661374*^9}, 
   3.665071512236197*^9, 3.665071699997882*^9, 3.665072213278562*^9, 
   3.665072247063212*^9, 3.665072302253025*^9, {3.665072352853303*^9, 
   3.66507236396906*^9}, {3.665072971504951*^9, 3.6650730065083857`*^9}, 
   3.6650730728468943`*^9, 3.665074108768221*^9, 3.665074148034444*^9, 
   3.6651540832960587`*^9, 3.665154320487912*^9, {3.665154364328169*^9, 
   3.665154367906761*^9}, {3.6651544053421497`*^9, 3.6651544511495523`*^9}, {
   3.665154535759304*^9, 3.6651545456097593`*^9}, 3.6651546314107857`*^9, 
   3.665154718308558*^9, {3.665154864485486*^9, 3.665154884137534*^9}}]
}, Open  ]]
}, Open  ]]
}, Open  ]]
},
WindowSize->{1035, 1229},
WindowMargins->{{55, Automatic}, {Automatic, 2}},
FrontEndVersion->"10.0 for Mac OS X x86 (32-bit, 64-bit Kernel) (September 9, \
2014)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{}
*)
(*CellTagsIndex
CellTagsIndex->{}
*)
(*NotebookFileOutline
Notebook[{
Cell[558, 20, 217, 3, 64, "Section"],
Cell[CellGroupData[{
Cell[800, 27, 103, 1, 50, "Section"],
Cell[906, 30, 1404, 39, 114, "Input"]
}, Open  ]],
Cell[CellGroupData[{
Cell[2347, 74, 150, 2, 64, "Section"],
Cell[2500, 78, 1744, 47, 84, "Input"]
}, Open  ]],
Cell[CellGroupData[{
Cell[4281, 130, 263, 3, 64, "Section"],
Cell[4547, 135, 1189, 28, 63, "Input"],
Cell[CellGroupData[{
Cell[5761, 167, 1914, 46, 114, "Input"],
Cell[CellGroupData[{
Cell[7700, 217, 976, 16, 21, "Print"],
Cell[8679, 235, 1153, 22, 21, "Print"]
}, Open  ]]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[9893, 264, 315, 4, 64, "Section"],
Cell[10211, 270, 1239, 28, 63, "Input"],
Cell[CellGroupData[{
Cell[11475, 302, 2014, 47, 114, "Input"],
Cell[CellGroupData[{
Cell[13514, 353, 1024, 16, 21, "Print"],
Cell[14541, 371, 1207, 22, 21, "Print"]
}, Open  ]]
}, Open  ]]
}, Open  ]]
}
]
*)

(* End of internal cache information *)
